package com.lwg.vhr.service.impl;

import com.lwg.vhr.mapper.PositionMapper;
import com.lwg.vhr.model.Position;
import com.lwg.vhr.service.PositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class PositionServiceImpl implements PositionService {

    @Autowired
    private PositionMapper positionMapper;

    public List<Position> getAllPositions() {
        return positionMapper.getAllPositions();
    }

    @Override
    public Integer addPosition(Position position) {
        position.setcreateDate(new Date());
        position.setEnabled(true);
        return positionMapper.insert(position);
    }

    @Override
    public Integer updatePositions(Position position) {
        position.setcreateDate(new Date());
        return positionMapper.updateByPrimaryKeySelective(position);
    }

    @Override
    public Integer deletePositionById(Integer id) {
        return positionMapper.deleteByPrimaryKey(id);
    }

    @Override
    public Integer deletePositionsByIds(Integer[] ids) {
        return positionMapper.deletePositionsByIds(ids);
    }
}
